<template>
	<view class="page">
		<view class="container">
			<view class="box">
				<scroll-view scroll-y="true" class="scroll-img" :style="show && 'height:100%' " >
					<image :src="resultList.value" class="png" mode="widthFix" style="width: 100%;height: calc(100vh-60px);"></image>
				</scroll-view>
			</view>
		</view>
	</view>
	<!-- <web-view  src=" https://apitest.hrzhizhang.com/admin/article/index"></web-view> -->

</template>

<script>
	export default {
		data() {
			return {
				title:'',
				resultList:[],
				scrollHeight:'460px',
				modalName:null,
				inquiry:'',
				inquiry_tel:'',
				msg:'',
				contactInfo:{},
				srv_id:0,
        index:0,
				show_nav:true
			};
		},

		onLoad(option) {
			console.log(option);
			let index = option.index;
			this.index = index;

			let obj = uni.getSystemInfoSync();
			let clientHeight = obj.screenHeight;
			this.scrollHeight = clientHeight-50+'px';

			this.getSys()

		},
		methods: {
			callTel(){
				uni.makePhoneCall({
					phoneNumber: this.contactInfo.serTel
				});
			},
			//平台联系方式
      //获取后端配置
      async getSys(){
        let t = this;
        let param = {
          'setting':'platform',
        };

        let data = await this.$http.post(
          'wx/platConfigs', //可以直接放链接(将不启用全局定义域名)
          param,
        );
        t.resultList = data[t.index]
        console.log(t.resultList);
        uni.setNavigationBarTitle({
          title:  t.resultList.name
        });
      },
			hideModal(){
				this.modalName=null
			},
      copyMessage(e){
        console.log(e);
        uni.setClipboardData({
          data: e,
          showToast:false,
          success: function () {
            console.log('success');
            uni.showToast({
              title:'服务信息已复制',
              mask:true,
              icon:'none',
              duration:3000,
            })
          }
        });
      },
			confirm() {
				const t=this
				if(!t.inquiry){
					return uni.showToast({
						title:'请输入姓名',
						icon:'none'
					})
				}
				if(!t.inquiry_tel){
					return uni.showToast({
						title:'请输入联系方式',
						icon:'none'
					})
				}
				if(!t.msg){
					return uni.showToast({
						title:'请输入留言',
						icon:'none'
					})
				}
				t.submit()
			},
			async submit(){
				const t=this
				let params={
					name:t.inquiry,
					mobile:t.inquiry_tel,
					msg:t.msg,
					srv_id:t.srv_id
				}
				let res=await this.$http.post('addSuggest',params)
				t.backPage()
			},
			backPage(){
				uni.showToast({
					title:'留言成功',
					mask:true,
				})
				setTimeout(()=>{
					this.modalName=null
				},1500)
			},
			/**
			 * 请求静态数据只是为了代码不那么乱
			 * 分次请求未作整合
			 */
			scheme(){
				var that = this;
				console.log(that.resultList.pdf_path);
				if(that.resultList.pdf_path=='undefined'||that.resultList.pdf_path==''||that.resultList.pdf_path==undefined){
					return uni.showToast({
						title:'此项目暂无方案附件',
						mask:true,
						icon:'none'
					})
				}
				uni.showLoading({
				  title: '文档下载中...',
				  mask: true
				});
				// if(path=='') return
				uni.downloadFile({
					url: that.resultList.pdf_path,
					success: function (res) {
					console.log(res)
					uni.hideLoading()
					const filePath = res.tempFilePath
					uni.openDocument({
						filePath: filePath,
						showMenu: true, // 是否显示右上角菜单
						fileType: 'pdf',
						success: function (res) {
							console.log('打开文档成功')
						},
						fail() {
							return uni.showToast({
								title:'此项目暂无',
								mask:true,
								icon:'none'
							})
						}
					})
					},
          fail(){
            uni.hideLoading()
          }
				})
			},
			//咨询
			consult(){
				this.modalName='interact'
			},
			async loadData() {
			  let t = this
				let param = {title:t.title};
				let data = await this.$http.post(
					'serviceInfo', //可以直接放链接(将不启用全局定义域名)
					param,
				);
				if(data==undefined||data==null){
					uni.showToast({
						title: `服务详情获取错误...`,
						icon: 'none'
					})
				}
				else{
					this.resultList = data;
				}


				console.log(data);

			},

			//详情页
			navToDetailPage(item) {
				if(!this.hasLogin){
					uni.navigateTo({
						url: '/pages/public/login'
					})
					return
				}
				// uni.showToast({
				// 	title: `功能开发中...`,
				// 	icon: 'none'
				// })
				// return
				//测试数据没有写id，用title代替
				let id = item.title;
				uni.navigateTo({
					url: `/pages/works/detail?id=${id}`
				})
			},
		},

	}
</script>

<style lang="scss">

	.page{
		height: 100vh;
		width: 100vw;
		background: #F6F6F6;
		overflow: hidden;
		.online{
			width: 100%;
			height: 10%;
			background-color: #fff;
			display: flex;
			justify-content: space-around;
			align-items: center;
			position: fixed;
			bottom: 0px;
			.item{
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				image{
					width: 25px;
				}
			}
		}
		.cu-modal {
			.cu-dialog{
				font-size: 15px;
				.list{
					width:100%;
					height: 50px;
					display: flex;
					justify-content: space-between;
					padding: 15px ;
					align-items: center;
					border-bottom: 1px solid #cbcbcb;
					.white-nowrap{
						white-space: nowrap;
					}
				}
				.text-area{
					text-align: left;
				}
			}
		}
	}
	.container{
		width: 100%;
		height: 100%;

		.box{
			width: 100%;
			height: 100%;
			margin-bottom: 0px;
			background: #FFFFFF;
			// .uni-padding-wrap{
			// 	width: 100%;
			// 	height: 100%;
			// 	.uni-common-mt{
			// 		width: 100%;
			// 		height: 100%;
					.scroll-img{
						width: 100%;
						height:  90%;
						overflow: hidden;
					}
			// 	}
			// }
			.my-serives{
				// width: 60px;
				// height: 60px;
				// position: fixed;
				// right: 20px;
				// button:30px
				image{
					width: 60px;
					height: 60px;
					position: fixed;
					right: 20px;
					bottom: 70px;
				}
			}
		}
	}

	.myCode{
		// position: absolute;
		width: 100%;
		height: 100px;
	}
	.bottom{
		height: 150px;
	}
	.content{
		height: 100px;
		padding: 0;
		background: #FFFFFF;
		// border: 1px solid #4CA5FE;
		// box-shadow: 0px 3px 6px rgba(76, 165, 254, 0.3);
		opacity: 1;
		border-radius: 10px;
		margin: 5% 15px;
		position: fixed;
		bottom: 10px;
		width: 90%;
	}

</style>
